<?php
/**
 * FootballFactory, Copyright Robin Loop & Pascal Wirz, 2013
 * ---
 * Diese Klasse stellt alle Datenbank-Operationen zur Verfuegung
 *
 * @author Robin
 */

require_once($_SERVER['DOCUMENT_ROOT']."/ff_config.php");

class Database extends PDO {
	
    public function __construct() {
        $dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME.';charset=utf8';
        
        $options = array(
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'",
            PDO::MYSQL_ATTR_READ_DEFAULT_FILE => '/etc/my.cnf'
        );
        
        set_exception_handler(array(__CLASS__, 'exception_handler'));
        parent::__construct($dsn, DB_USER, DB_PASS);
        restore_exception_handler();
        
        return $this;
    }
        
    public static function exception_handler($exception) {
        print "Exception in class_database: ".$exception;
        die();
    }
}



?>